﻿    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LowLevelGraphics.Filter
{
    /// <summary>
    /// Z = imlincomb(K1,A1,K2,A2,...,Kn,An) computes
    /// K1*A1 + K2*A2 + ... + Kn*An
    /// where K1, K2, through Kn are real, double scalars and A1, A2, through An are real, nonsparse, numeric arrays with the same class and size. Z has the same class and size as A1.
    /// Z = imlincomb(K1,A1,K2,A2,...,Kn,An,K) computes
    /// K1*A1 + K2*A2 + ... + Kn*An + K
    /// where imlincomb adds K, a real, double scalar, to the sum of the products of K1 through Kn and A1 through An.
    /// Z = imlincomb(...,output_class) lets you specify the class of Z. output_class is a string containing the name of a numeric class.
    /// When performing a series of arithmetic operations on a pair of images, you can achieve more accurate results if you use imlincomb to combine the operations, rather than nesting calls to the individual arithmetic functions, such as imadd. When you nest calls to the arithmetic functions, and the input arrays are of an integer class, each function truncates and rounds the result before passing it to the next function, thus losing accuracy in the final result. imlincomb computes each element of the output Z individually, in double-precision floating point. If Z is an integer array, imlincomb truncates elements of Z that exceed the range of the integer type and rounds off fractional values.
    /// On Intel architecture processors, imlincomb can take advantage of the Intel Integrated Performance Primitives (Intel IPP) library, thus accelerating its execution time. The Intel IPP library is activated only in the following cases:
    /// Z = imlincomb( 1.0, A1, 1.0, A2)
    /// Z = imlincomb( 1.0, A1,-1.0, A2)
    /// Z = imlincomb(-1.0, A1, 1.0, A2)
    /// Z = imlincomb( 1.0 , A1, K)
    /// where A1, A2, and Z are of class uint8, int16, or single and are of the same class.
    /// </summary>
    public class imlincomb : BaseImageFilter, ITwoSourceFilter
    {
        /// <summary>
        /// 
        /// </summary>
        public imlincomb()
        {
        }

        /// <summary>
        /// internal constructor used for cloning
        /// </summary>
        /// <param name="_imlinecomb"></param>
        internal imlincomb(imlincomb _imlinecomb)
        {
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="_bitmap1"></param>
        /// <param name="_bitmap2"></param>
        /// <returns></returns>
        public UnsafeBitmap Process(UnsafeBitmap _bitmap1, UnsafeBitmap _bitmap2)
        {
            return _bitmap2;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="_bitmap"></param>
        /// <returns></returns>
        public override UnsafeBitmap Execute(UnsafeBitmap _bitmap)
        {
            return Process((UnsafeBitmap)_bitmap.Clone(), _bitmap);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override object  Clone()
        {
            return new imlincomb(this);
        }     
    }
}
